const fs = require("fs");
const path = require('node:path')
const AdmZip = require('adm-zip'); //引入查看zip文件的包
console.log(path.resolve(__dirname,'./docxtemplater/loops.docx'))
const zip = new AdmZip(path.resolve(__dirname,'./454.docx') );
let contentXml = zip.readAsText("word/document.xml");//将document.xml读取为text内容；
let str = "";
contentXml.match(/<w:t>[\s\S]*?<\/w:t>/ig).forEach((item)=>{
str += item.slice(5,-6)});
fs.writeFile("./2.txt",str,(err)=>{//将./2.txt替换为你要输出的文件路径
if(err)throw err;
});